package com.bj58.data.emailreports.controllers;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bj58.data.emailreports.model.NetflowWRData;
import com.bj58.data.emailreports.service.NetflowWeekReportService;
import com.bj58.data.emailreports.utils.DateUtil;
import com.bj58.data.emailreports.utils.EmailReportUtil;
import com.bj58.data.emailreports.utils.MailUtil;
import com.bj58.data.emailreports.utils.MyStore;
import com.bj58.data.emailreports.utils.ResourcesUtil;
import com.bj58.data.emailreports.utils.SortUtil;
import com.bj58.data.emailreports.utils.VelocityTools;
import com.bj58.groupbuy.service.locator.ServiceLocator;
import com.bj58.groupbuy.util.PathUtil;

/**流量数据分析周报
 * @author guoxue
 *
 */
public class NetflowWeekReportController {
	private NetflowWeekReportService netflowWeekReportService= ServiceLocator.get(NetflowWeekReportService.class);
	private EmailReportUtil eru = new EmailReportUtil();
	
	private String[] business_58={"all","fangchan","zhaopin","huangye","ershouche","ershouchuangxin","ershoutuiguang"};
	private String[] business_ganji={"all","fangchan","zhaopin","huangye","ershouche","ershou"};
	
	private String[] source_58pc={"all","ziyou","sem","seo","guanggaoxilie","lianmeng","qita"};
	private String[] source_58m={"all","ziyou","sem","seo","qita","fufeiliulanqi","fufeiqita","shoujiqq","momo","weixilie","lianmeng"};	
	private String[] source_ganji={"all","ziyou","sem","seo","fufei","qita"};
	
	
	/**第一部分  全站 - 全站流量及运营数据/流量PC来源数据数据/流量M来源数据数据/全站PC端流量数据	/全站M端流量数据/全站APP端流量数据/业务线流量数据
	 * @param searchDate
	 * @return
	 */
	public String weekReportPartOne(String searchDate){
		try {
			//读取模板内容
			String filepath =PathUtil.getWFNamespaceFolder()+"/emailtemp/NetflowWeekReport.html";
			String templateContext = ResourcesUtil.getTemByPath(filepath);
			//渲染MAP
			Map<String,Object> conMap = new HashMap<String,Object>();
			//查询日期
			Date  sDate = DateUtil.strToDate(searchDate, "yyyy-MM-dd");
			String today = DateUtil.getStringDate(sDate,"yyyy-MM-dd");//查询日期（今）
			String yesterday = DateUtil.getStringDate(DateUtil.getDateBefore(sDate, 1),"yyyy-MM-dd");//查询日期（昨）
			String lastWeek = DateUtil.getStringDate(DateUtil.getDateBefore(sDate, 7),"yyyy-MM-dd");//查询日期（上周）
			String beginday = DateUtil.getStringDate(DateUtil.getDateBefore(sDate, 6),"yyyy-MM-dd");//查询日期 放标题
			
			List<String> dateList = new ArrayList<String>();
			dateList.add(today);dateList.add(yesterday);dateList.add(lastWeek);
			
			List<String> dateList_search = new ArrayList<String>();
			dateList_search.add(today);dateList_search.add(lastWeek);
			
			conMap.put("today", today.replaceAll("-", "."));
			conMap.put("yesterday", yesterday.replaceAll("-", "."));
			conMap.put("lastWeek", lastWeek.replaceAll("-", "."));
			conMap.put("beginday", beginday.replaceAll("-", "."));
				
			List<String> showCols = new ArrayList<String>(); //同比环比计算指标集
			List<String> percentList = new ArrayList<String>();//百分比指标集
			
			String[] companyArray={"58","ganji"};
			conMap.put("business", MyStore.busilineTran("all"));
		
			
			//全站流量及运营数据			
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");
			showCols.add("pv");showCols.add("pvZb");showCols.add("vppv_uv");
			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");percentList.add("pvZb");
	
			Map<String,List<NetflowWRData>> NWRALLDataMap = netflowWeekReportService.getNWRplatformDataMap(dateList_search,"all");
			List<String> NWRALLData=new ArrayList<String>();
			for(String company:companyArray){
				
				if(NWRALLDataMap.containsKey(company)){
					List<NetflowWRData> tempList = NWRALLDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_platform(NWRALLData,dataList);
					
				}
			}		
			conMap.put("NWRALLData", NWRALLData);
			
			
			//流量PC来源数据数据			
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");
			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			Map<String,List<NetflowWRData>> NWRPCSourceDataMap = netflowWeekReportService.getNWRSourceDataMap(dateList_search,"pc","all");
			List<String> NWRPCSourceData=new ArrayList<String>();
	
			for(String company:companyArray){
				
				if(NWRPCSourceDataMap.containsKey(company)){
					List<NetflowWRData> tempList = NWRPCSourceDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(NWRPCSourceData,dataList,company,"pc");
					
				}
			}	
			conMap.put("NWRPCSourceData", NWRPCSourceData);
		
			
			//流量M来源数据数据		
			Map<String,List<NetflowWRData>> NWRMSourceDataMap =  netflowWeekReportService.getNWRSourceDataMap(dateList_search,"m","all");
			List<String> NWRMSourceData=new ArrayList<String>();
	
			for(String company:companyArray){
				
				if(NWRMSourceDataMap.containsKey(company)){
					List<NetflowWRData> tempList = NWRMSourceDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(NWRMSourceData,dataList,company,"m");
					
				}
			}	
			conMap.put("NWRMSourceData", NWRMSourceData);
			
				
			//全站PC端流量数据		
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");
			showCols.add("pv");showCols.add("pvZb");showCols.add("vppv_uv");		
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");percentList.add("pvZb");
			
			Map<String,List<NetflowWRData>> NWRPCALLDataMap = netflowWeekReportService.getNWRBusiDataMap(dateList_search,"pc",business_58,business_ganji);
			List<String> NWRPCALLData=new ArrayList<String>();
			
			for(String company:companyArray){
				
				if(NWRPCALLDataMap.containsKey(company)){
					List<NetflowWRData> tempList = NWRPCALLDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData(NWRPCALLData,dataList,company);
					
				}
			}	
			conMap.put("NWRPCALLData", NWRPCALLData);
		
			
			//全站M端流量数据	
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");
			showCols.add("pv");showCols.add("pvZb");showCols.add("vppv_uv");		
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");percentList.add("pvZb");
			Map<String,List<NetflowWRData>> NWRMALLDataMap = netflowWeekReportService.getNWRBusiDataMap(dateList_search,"m",business_58,business_ganji);
			List<String> NWRMALLData=new ArrayList<String>();
			
			for(String company:companyArray){
				
				if(NWRMALLDataMap.containsKey(company)){
					List<NetflowWRData> tempList = NWRMALLDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData(NWRMALLData,dataList,company);
					
				}
			}	
			conMap.put("NWRMALLData", NWRMALLData);
			
			
			//全站APP端流量数据			
			Map<String,List<NetflowWRData>> NWRAPPALLDataMap = netflowWeekReportService.getNWRBusiDataMap(dateList_search,"app",business_58,business_ganji);
			List<String> NWRAPPALLData=new ArrayList<String>();
			
			for(String company:companyArray){
				
				if(NWRAPPALLDataMap.containsKey(company)){
					List<NetflowWRData> tempList = NWRAPPALLDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData(NWRAPPALLData,dataList,company);
					
				}
			}	
			conMap.put("NWRAPPALLData", NWRAPPALLData);
						
			
			//全站流量数据	  前面pc m app的加和			
			showCols.clear();
			showCols.add("vppv");showCols.add("uv");showCols.add("pv");showCols.add("vppv_uv");		
					
			Map<String,List<NetflowWRData>> NWRALLPlatDataMap =  netflowWeekReportService.getNWRADDMap(dateList,NWRPCALLDataMap,NWRMALLDataMap,NWRAPPALLDataMap,"all");

            List<String> NWRALLPlatData=new ArrayList<String>();	
			for(String company:companyArray){
				
				if(NWRALLPlatDataMap.containsKey(company)){
					List<NetflowWRData> tempList = NWRALLPlatDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
					
					dataList = SortUtil.sortListByFileName(dataList, 1, 2);
					showData(NWRALLPlatData,dataList,company);
				}
			}	
			conMap.put("NWRALLPlatData", NWRALLPlatData);			
		
			
			return VelocityTools.render(templateContext, conMap);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	
	/**第二部分  招聘/黄页/二手创新
	 * @param searchDate
	 * @return
	 */
	public String weekReportPartTwo(String searchDate,String business){
		try {
			//读取模板内容
			String filepath =PathUtil.getWFNamespaceFolder()+"/emailtemp/NetflowWeekReport.html";
			String templateContext = ResourcesUtil.getTemByPath(filepath);
			//渲染MAP
			Map<String,Object> conMap = new HashMap<String,Object>();
			//查询日期
			Date  sDate = DateUtil.strToDate(searchDate, "yyyy-MM-dd");
			String today = DateUtil.getStringDate(sDate,"yyyy-MM-dd");//查询日期（今）
			String yesterday = DateUtil.getStringDate(DateUtil.getDateBefore(sDate, 1),"yyyy-MM-dd");//查询日期（昨）
			String lastWeek = DateUtil.getStringDate(DateUtil.getDateBefore(sDate, 7),"yyyy-MM-dd");//查询日期（上周）
			String beginday = DateUtil.getStringDate(DateUtil.getDateBefore(sDate, 6),"yyyy-MM-dd");//查询日期 放标题
			
			List<String> dateList = new ArrayList<String>();
			dateList.add(today);dateList.add(yesterday);dateList.add(lastWeek);
			
			List<String> dateList_search = new ArrayList<String>();
			dateList_search.add(today);dateList_search.add(lastWeek);
			
			conMap.put("today", today.replaceAll("-", "."));
			conMap.put("yesterday", yesterday.replaceAll("-", "."));
			conMap.put("lastWeek", lastWeek.replaceAll("-", "."));
			conMap.put("beginday", beginday.replaceAll("-", "."));
				
			List<String> showCols = new ArrayList<String>(); //同比环比计算指标集
			List<String> percentList = new ArrayList<String>();//百分比指标集
			
			String[] companyArray={"58","ganji"};
			conMap.put("business", MyStore.busilineTran(business));
			
			
			//业务线流量及运营数据			
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");
			showCols.add("pv");showCols.add("pvZb");showCols.add("vppv_uv");
			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");percentList.add("pvZb");
	
			Map<String,List<NetflowWRData>> platformDataMap = netflowWeekReportService.getNWRplatformDataMap(dateList_search,business);
			List<String> platformALLData=new ArrayList<String>();
			for(String company:companyArray){
				
				if(platformDataMap.containsKey(company)){
					List<NetflowWRData> tempList = platformDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_platform(platformALLData,dataList);
					
				}
			}	
			conMap.put("platformALLData", platformALLData);		
		
			
			//流量PC来源数据数据							
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");
			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			
			Map<String,List<NetflowWRData>> PCSourceDataMap = netflowWeekReportService.getNWRSourceDataMap(dateList_search,"pc",business);
			List<String> BusiPCSourceData=new ArrayList<String>();
			
			for(String company:companyArray){
				
				if(PCSourceDataMap.containsKey(company)){
					List<NetflowWRData> tempList = PCSourceDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(BusiPCSourceData,dataList,company,"pc");
					
				}
			}	
			conMap.put("BusiPCSourceData", BusiPCSourceData);
			

			//流量M来源数据数据		
			showCols.clear();
			showCols.add("vppv");showCols.add("vppvZb");showCols.add("uv");showCols.add("uvZb");showCols.add("vppv_uv");
			
			percentList.clear();
			percentList.add("vppvZb");percentList.add("uvZb");
			Map<String,List<NetflowWRData>> MSourceDataMap = netflowWeekReportService.getNWRSourceDataMap(dateList_search,"m",business);
			List<String> BusiMSourceData=new ArrayList<String>();
			
			for(String company:companyArray){
				
				if(MSourceDataMap.containsKey(company)){
					List<NetflowWRData> tempList = MSourceDataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
					
					showData_source(BusiMSourceData,dataList,company,"m");
					
				}
			}	
			conMap.put("BusiMSourceData", BusiMSourceData);
		
			
			//重点PC端类别流量数据		
			showCols.clear();
			showCols.add("vppv");showCols.add("uv");showCols.add("pv");showCols.add("vppv_uv");
			
			Map<String,List<NetflowWRData>> PCCate1DataMap = netflowWeekReportService.getNWRCate1DataMap(dateList_search,"pc",business);
			List<String> PCCate1Data=new ArrayList<String>();
			
			int PCcatenum_58=0;
			int PCcatenum_ganji=0;
			for(String company:companyArray){
				
				if(PCCate1DataMap.containsKey(company)){
					List<NetflowWRData> tempList = PCCate1DataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
					dataList = SortUtil.sortListByFileName(dataList, 1, 2);
					if(company.equals("58"))
					{
						PCcatenum_58=showData_cate(PCCate1Data,dataList,company);
					}else
					{
						PCcatenum_ganji=showData_cate(PCCate1Data,dataList,company);
					}
				}
			}	
			conMap.put("PCCate1Data", PCCate1Data);
			conMap.put("PCcatenum_58", PCcatenum_58);
			conMap.put("PCcatenum_ganji", PCcatenum_ganji);
			
			
			//重点M端类别流量数据		
			showCols.clear();
			showCols.add("vppv");showCols.add("uv");showCols.add("pv");showCols.add("vppv_uv");
			
			Map<String,List<NetflowWRData>> MCate1DataMap = netflowWeekReportService.getNWRCate1DataMap(dateList_search,"m",business);
			List<String> MCate1Data=new ArrayList<String>();
			int Mcatenum_58=0;
			int Mcatenum_ganji=0;
			for(String company:companyArray){
				
				if(MCate1DataMap.containsKey(company)){
					List<NetflowWRData> tempList = MCate1DataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
					dataList = SortUtil.sortListByFileName(dataList, 1, 2);
					
					if(company.equals("58"))
					{
						Mcatenum_58=showData_cate(MCate1Data,dataList,company);
					}else
					{
						Mcatenum_ganji=showData_cate(MCate1Data,dataList,company);
					}	
				}
			}	
			conMap.put("MCate1Data", MCate1Data);
			conMap.put("Mcatenum_58", Mcatenum_58);
			conMap.put("Mcatenum_ganji", Mcatenum_ganji);
			
			
			//重点APP端类别流量数据		
			showCols.clear();
			showCols.add("vppv");showCols.add("uv");showCols.add("pv");showCols.add("vppv_uv");
			
			Map<String,List<NetflowWRData>> APPCate1DataMap = netflowWeekReportService.getNWRCate1DataMap(dateList_search,"app",business);
			List<String> APPCate1Data=new ArrayList<String>();
			
			int APPcatenum_58=0;
			int APPcatenum_ganji=0;
			for(String company:companyArray){
				
				if(APPCate1DataMap.containsKey(company)){
					List<NetflowWRData> tempList = APPCate1DataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
					dataList = SortUtil.sortListByFileName(dataList, 1, 2);
					
					if(company.equals("58"))
					{
						APPcatenum_58=showData_cate(APPCate1Data,dataList,company);
					}else
					{
						APPcatenum_ganji=showData_cate(APPCate1Data,dataList,company);
					}					
					
				}
			}	
			conMap.put("APPCate1Data", APPCate1Data);
			conMap.put("APPcatenum_58", APPcatenum_58);
			conMap.put("APPcatenum_ganji", APPcatenum_ganji);
			
		
			//重点类别流量数据  前面pc m app的加和		
			Map<String,List<NetflowWRData>> Cate1DataMap =  netflowWeekReportService.getNWRADDMap(dateList,PCCate1DataMap,MCate1DataMap,APPCate1DataMap,business);

            List<String> NMRCate1Data=new ArrayList<String>();	
            int catenum_58=0;
			int catenum_ganji=0;
			for(String company:companyArray){
				
				if(Cate1DataMap.containsKey(company)){
					List<NetflowWRData> tempList = Cate1DataMap.get(company);
					List<String> dataList = eru.conformDataTypeFour(tempList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
					
					dataList = SortUtil.sortListByFileName(dataList, 1, 2);
					if(company.equals("58"))
					{
						catenum_58=showData_cate(NMRCate1Data,dataList,company);
					}else
					{
						catenum_ganji=showData_cate(NMRCate1Data,dataList,company);
					}	
					
				}
			}	
			conMap.put("NMRCate1Data", NMRCate1Data);
			conMap.put("catenum_58", catenum_58);
			conMap.put("catenum_ganji", catenum_ganji);
	
			
			//58重点二级类KPI数据指标 pc端		
			showCols.clear();
			showCols.add("uv");showCols.add("vppv");showCols.add("vppv_uv");showCols.add("range_rate");showCols.add("jumpout_rate");
			
			percentList.clear();
			percentList.add("jumpout_rate");percentList.add("range_rate");
			
			List<NetflowWRData> PCCate2DataList = netflowWeekReportService.getNWRCate2Data(dateList_search,"pc",business);
			List<String> PCCate2Data=new ArrayList<String>();
		
			List<String> pcdataList = eru.conformDataTypeFour(PCCate2DataList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
			pcdataList = SortUtil.sortListByFileName(pcdataList, 1, 2);
			showData_cate(PCCate2Data,pcdataList,"58");								
			conMap.put("PCCate2Data", PCCate2Data);
			
			
			//58重点二级类KPI数据指标 m端		
			showCols.clear();
			showCols.add("uv");showCols.add("vppv");showCols.add("vppv_uv");showCols.add("jumpout_rate");
			
			percentList.clear();
			percentList.add("jumpout_rate");
			
			List<NetflowWRData> MCate2DataList = netflowWeekReportService.getNWRCate2Data(dateList_search,"m",business);
			List<String> MCate2Data=new ArrayList<String>();
		
			List<String> mdataList = eru.conformDataTypeFour(MCate2DataList, NetflowWRData.class, "type", showCols, "statDate", percentList, dateList);
			mdataList = SortUtil.sortListByFileName(mdataList, 1, 2);
			showData_cate(MCate2Data,mdataList,"58");
			conMap.put("MCate2Data", MCate2Data);
				
			
			//58重点二级类KPI数据指标 app端		
			showCols.clear();
			showCols.add("uv");showCols.add("vppv");showCols.add("vppv_uv");
			
			List<NetflowWRData> APPCate2DataList = netflowWeekReportService.getNWRCate2Data(dateList_search,"app",business);
			List<String> APPCate2Data=new ArrayList<String>();
		
			List<String> appdataList = eru.conformDataTypeFour(APPCate2DataList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
			appdataList = SortUtil.sortListByFileName(appdataList, 1, 2);
			showData_cate(APPCate2Data,appdataList,"58");
			conMap.put("APPCate2Data", APPCate2Data);
			
			
			//58重点二级类KPI数据指标  前面pc m app的加和		
			List<NetflowWRData> Cate2DataList =  netflowWeekReportService.getNWRADDList(dateList,PCCate2DataList,MCate2DataList,APPCate2DataList);

            List<String> NMRCate2Data=new ArrayList<String>();		

			List<String> Cate2dataList = eru.conformDataTypeFour(Cate2DataList, NetflowWRData.class, "type", showCols, "statDate", null, dateList);
					
			Cate2dataList = SortUtil.sortListByFileName(Cate2dataList, 1, 2);
			showData_cate(NMRCate2Data,Cate2dataList,"58");			
			conMap.put("NMRCate2Data", NMRCate2Data);
			
			
			return VelocityTools.render(templateContext, conMap);
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	public void showData_platform(List<String> rslist,List<String> dataList)throws Exception {
		
		String[] platform={"all","pc","m","app"};
	
		for(String p:platform)
		{
			for(String s:dataList){
				String a=s.split(";")[0];
				a=a.substring(s.lastIndexOf("_")+1,a.length());	
				
				if(a.equals(p))
				{											
					a=a.replaceAll(p, MyStore.platformTran(p));
					s=a+s.substring(s.indexOf(";"));
					
					rslist.add(s);
					break;
				}
			}
		}		
	}	
	
	public int showData_cate(List<String> rslist,List<String> dataList,String company)throws Exception {
			
		int num=0;
		for(String s:dataList){
			String a=s.split(";")[0];
			
			if(a.contains("all"))
				continue;
			if(a.contains(company))
				num++;
			
			a=a.substring(s.lastIndexOf("_")+1,a.length());	
		
			s=a+s.substring(s.indexOf(";"));			
			rslist.add(s);	
		}	
		
		return num;
	}
	
	public void showData_source(List<String> rslist,List<String> dataList,String cate,String platform)throws Exception {
		
		String sourceArray[]={};
		
		if(cate.equals("58") && platform.equals("pc")){
			sourceArray=source_58pc;			
		}else if(cate.equals("58") && platform.equals("m")){
			sourceArray=source_58m;		
		}else if(cate.equals("ganji")){
			sourceArray=source_ganji;		
		}					
			
		for(String source:sourceArray)
		{
			for(String s:dataList){
				String a=s.split(";")[0];
				a=a.substring(s.lastIndexOf("_")+1,a.length());	
				
				if(a.equals(source))
				{											
					a=a.replaceAll(source, MyStore.sourceTran(source));
					s=a+s.substring(s.indexOf(";"));
					
					rslist.add(s);
					break;
				}
			}
		}		
	}	
	
	//表头左侧放 58 赶集 
	public void showData(List<String> rslist,List<String> dataList,String company)throws Exception {
			
		String business[]={};
		
		if(company.equals("58")){
			business=business_58;			
		}else{
			business=business_ganji;	
		}	
		
		for(String busi:business)
		{
			for(String s:dataList){
				String a=s.split(";")[0];
				a=a.substring(s.lastIndexOf("_")+1,a.length());	
				
				if(a.equals(busi))//如果直接contain，ershou和ershouche会混淆
				{											
					a=a.replaceAll(busi, MyStore.busilineTran(busi));
					s=a+s.substring(s.indexOf(";"));
					
					rslist.add(s);
					break;
				}
			}
		}	
			
	}
	public static void main(String[] args) {
		try {
			String searchDate="2016-03-14 ";//周日
			NetflowWeekReportController test = new NetflowWeekReportController();
			String content = test.weekReportPartOne(searchDate);
			//String content = test.weekReportPartTwo(searchDate,"zhaopin");
			//String content = test.weekReportPartTwo(searchDate,"huangye");
			//String content = test.weekReportPartTwo(searchDate,"ershouchuangxin");
			
			if(!"".equals(content)){
				String text="流量数据周报测试  "+searchDate;
				MailUtil.javaMailSend(text, content, "guoxue@58.com",null);
				
//				String text="流量数据周报   2016.02.15~2016.02.21"+searchDate;
//				MailUtil.javaMailSend(text, content, "liangxiao01@58.com;wuxueqi@58.com;shihaiqing@58.com;huangjuan@58.com;ecdata@58.com;",null);
			}else{
				//邮件报警
//				content = "流量数据周报报错！";
//		    	MailUtil.javaMailSend("email report error", content, "guoxue@58.com",null);
//		    	Map<String,String> telMap=new HashMap<String,String>();
//		    	telMap.put("15726690526","email report error:"+content);
//		    	SubmitSms.submitMsg(telMap);
			
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
